var devUrl = "http://localhost:8080";
var testUrl = "https://www.hgtool.top:9443";
var proUrl = "https://www.hgtool.top:8443";

//6874100106147

const formatTime = date => {

    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    const weekDay = date.getDay();
    return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':');
}
const formatDate = date => {
    var date1 = date1 + "";
    date1 = date1.replace(/-/g, '/'); // 日期格式处理

    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()

    return [year, month, day].map(formatNumber).join('-');
}


const formatDay = date => {
    var weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];

    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    const weekDay = date.getDay();
    return [year, month, day].map(formatNumber).join('-') + ' ' + weekdays[weekDay];
}

const formatNumber = n => {
    n = n.toString()
    return n[1] ? n : '0' + n
}

function requestFail() {
    wx.showModal({
        title: '温馨提示',
        content: '服务器繁忙,请稍后再试',
        showCancel: false
    });
}

function requestError(errorMsg) {
    if (!errorMsg || typeof(errorMsg) == "undefined" || errorMsg == '') {
        errorMsg = '服务器繁忙,请稍后再试';
    }
    console.log("请求错误:", errorMsg);
    wx.showModal({
        title: '温馨提示',
        content: errorMsg,
        showCancel: false
    });
}
module.exports = {
    baseUrl: proUrl,
    formatTime: formatTime,
    formatDay: formatDay,
    formatDate: formatDate,
    requestFail: requestFail,
    requestError: requestError
}